package com.luckberry.murder.mapper;

import com.luckberry.murder.entity.good.Good;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodMapper {

    @Select("select * from good")
    List<Good> getGoods();

    @Select("select * from good where name like '%' #{name} '%'")
    List<Good> getGoodsByName(String name);

    @Select("select * from good where type = #{type}")
    List<Good> getGoodsByType(String type);

    @Select("select * from good where gid = #{gid}")
    Good getGood(int gid);

    @Insert("insert into good(name, price, type, count, face) VALUES (#{name}, #{price}, #{type}, #{count}, #{face})")
    int addGood(Good good);

    @Delete("delete good from good where gid = #{gid}")
    int deleteGood(int gid);

    @Update("update good set name = #{name}, price = #{price}, type = #{type}, count = #{count}, face = #{face} where gid = #{gid}")
    int editGood(Good good);
}
